package com.project.role;

import com.project.frame.GameStartFrame;
import com.project.util.ImageChange;
import com.project.util.KeyPress;

import java.awt.*;
import java.awt.event.KeyEvent;

public class Girl extends BaseRole implements Attack {
    /**
     * girl图片数组
     */
    public static Image[] girlImage;

    /**
     * 攻击间隔计次
     */
     public  static int attackSP;

    /**
     *图片切换算法对象
     */
    private ImageChange imageChange = new ImageChange(3);


    public Girl() {
        super(50, 100, 60, 40);
    }


    @Override
    public void move() {


        if (KeyPress.isUp) {
            y = Math.max(y - 8, 30);
        }
        if (KeyPress.isDown) {
            y = Math.min(y + 8, 650);
        }
        if (KeyPress.isRight) {
            x = Math.min(x + 8, 940);
        }
        if (KeyPress.isLeft) {
            x = Math.max(x - 8, 0);
        }
        this.img = imageChange.change(girlImage);
    }

    @Override
    public void collision() {

    }


    @Override
    public void shoot() {
        if (KeyPress.isAttack) {
            attackSP++;
            if (attackSP==5){
                attackSP=0;
                GameStartFrame.roleList.add(new GirlBullet());
            }
        }
    }
}

